package cn.itsource.service.impl;

import cn.itsource.domain.User;
import cn.itsource.mapper.UserMapper;
import cn.itsource.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional(propagation = Propagation.SUPPORTS,readOnly = true)
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;


    @Override
    public List<User> findAll() {
        return userMapper.findAll();
    }

    @Override
    public User findOne(int id) {
        return userMapper.findOne(id);
    }

    @Transactional
    @Override
    public void update(User user) {
        userMapper.update(user);
    }

    @Transactional  //事务
    @Override
    public void delete(int id) {
        userMapper.delete(id);
    }

    @Transactional
    @Override
    public void add(User user) {
        userMapper.add(user);
    }
}
